package August;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Day0804 {
    /**
     * 微信红包
     * @param gifts
     * @param n
     * @return
     */
    public int getValue(int[] gifts, int n) {
        Map<Integer,Integer> hashMap = new HashMap<>();
        //初始化
        for (int i = 0; i < gifts.length; i++) {
            if (!hashMap.containsKey(gifts[i])){
                hashMap.put(gifts[i],1);
            }else {
                hashMap.put(gifts[i],hashMap.get(gifts[i])+1);
            }
        }
        for (int i = 0; i < gifts.length; i++) {
            if (hashMap.get(gifts[i]) >= (n/2)){
                return gifts[i];
            }
        }
        return 0;
    }


    //计算字符串的编辑距离
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String a = scanner.nextLine();
        String b = scanner.nextLine();

        int[][] dp = new int[a.length()+1][b.length()+1];

        //动规数组初始化
        for (int i = 1; i <= a.length() ; i++) {
            dp[i][0] = i;
        }
        for (int i =1; i <= b.length() ; i++) {
            dp[0][i] = i;
        }


        for (int i = 1; i <= a.length() ; i++) {
            for (int j = 1; j <= b.length() ; j++) {
                if (a.charAt(i - 1) == b.charAt(j - 1))
                    dp[i][j] = dp[i-1][j-1];
                else {
                    dp[i][j] = Math.min(Math.min(dp[i-1][j],dp[i-1][j-1]),dp[i][j-1])+1;
                }
            }
        }
        System.out.println(dp[a.length()][b.length()]);
    }
}
